package com.fowo.api.service.handleWork.supplier;

import com.fowo.api.model.development.task.DevelopmentTaskVo;
import com.fowo.api.model.development.task.DevelopmentTaskWithdrawAction;
import com.fowo.api.service.impl.DevelopmentTaskServiceImpl;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

import javax.annotation.Resource;
import java.util.List;

@Component
public class developmentTaskWithdrawAction implements DevelopmentTaskWithdrawAction {
    @Resource
    private DevelopmentTaskServiceImpl developmentTaskService;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void run(List<Long> idList) throws Exception {
        for(int i=0;i<idList.size();i++){
            DevelopmentTaskVo voById = developmentTaskService.getVoById(idList.get(i));
            Assert.isTrue(voById.getState().equals("1"),"违规操作");
            voById.setState("4");
            developmentTaskService.update(voById);
        }
    }
}
